package com.example.demo.api;

import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.json.JSONUtil;
import com.example.demo.api.entity.QuerySqlEntity;
import com.example.demo.api.sql.CommonQueryService;
import com.example.demo.sql.SqlEntity;
import com.example.demo.sql.SqlUtil;
import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.parser.CCJSqlParserManager;
import net.sf.jsqlparser.statement.select.Select;

import java.io.StringReader;

public class TestMain {
    public static void main(String[] args) throws JSQLParserException {
        // 从资源目录中读取 param.json 文件
        String jsonContent = ResourceUtil.readUtf8Str("newParam.json");
        QuerySqlEntity sqlEntity = JSONUtil.toBean(jsonContent, QuerySqlEntity.class);

        System.out.println(sqlEntity);
        String sql = CommonQueryService.getSql(sqlEntity);
        System.out.println(sql);

//        String query = "SELECT ID FROM USER";
//        CCJSqlParserManager parserManager = new CCJSqlParserManager();
//        Select select = (Select) parserManager.parse(new StringReader(query));
//        System.out.println(select);

    }
}
